#include <windows.h>
#include "resource1.h"
#pragma warning(disable:4786)
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
DialogCmd(HWND hwndDlg,WPARAM wParam,LPARAM lParam)
{
	switch(LOWORD(wParam))
	{
	case IDOK:
        EndDialog(hwndDlg,IDOK);
	}
}
DialogInit(HWND hwndDlg,WPARAM wParam,LPARAM lParam)
{
	/*At first ,set the Dialog Icon(IDI_ICON1).*/
	HICON hIcon = LoadIcon((HINSTANCE) GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE),MAKEINTRESOURCE(IDI_ICON1));
	SendMessage(hwndDlg, WM_SETICON, TRUE,(LPARAM)hIcon);
    SendMessage(hwndDlg, WM_SETICON, FALSE, (LPARAM)hIcon);
	/*Add other initialize code here*/
}
INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
		DialogInit(hwndDlg,wParam,lParam);
		return TRUE;
	case WM_COMMAND:
		DialogCmd( hwndDlg, wParam,lParam);
		return TRUE;
	case WM_CLOSE:
		EndDialog(hwndDlg,IDOK);
		break;
	default:
		break;
	}		
	return FALSE;
}
void Exercise1()
{
	typedef vector<char>::reverse_iterator VRI;
	vector<char> VChar;
	for( char c = 'A';c<='z';c++)
		VChar.push_back(c);
	cout<<"The order in the VChar is:"<<endl;
	for(vector<char>::iterator vi = VChar.begin();vi!=VChar.end();vi++)
		cout<<*vi;
	cout<<endl;
	cout<<"The reverse order is :"<<endl;
	for( VRI vri = VChar.rbegin();vri !=VChar.rend();vri++)
		cout<<*vri;
	cout<<endl;
}
void Exercise2()
{
	vector <string> fruits;
	fruits.push_back("Apple");
	fruits.push_back("peach");
	fruits.push_back("kiwifuit");
	fruits.push_back("pear");
	fruits.push_back("starfruit");
	fruits.push_back("grape");
	cout<<"Befor the sorting:"<<endl;
	for(vector<string>::iterator vi =fruits.begin();vi != fruits.end();vi++)
		cout<<*vi<<" ";
	cout<<"sort the vector:"<<endl;
	sort(fruits.begin(),fruits.end());
	for(vector<string>::iterator vi =fruits.begin();vi != fruits.end();vi++)
		cout<<*vi<<" ";
}
void main()
{
	Exercise2();
	
	DialogBox((HINSTANCE)GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1),NULL,DialogProc);

}